package com.homeparking.manage.service.impl;

import java.util.List;
import com.homeparking.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.homeparking.manage.mapper.DayworkMapper;
import com.homeparking.manage.domain.Daywork;
import com.homeparking.manage.service.IDayworkService;
import static com.homeparking.common.utils.SecurityUtils.getUserId;
import static com.homeparking.common.utils.SecurityUtils.getUsername;

/**
 * 员工工作日志信息Service业务层处理
 * 
 * @author liuyangyang
 * @date 2025-04-23
 */
@Service
public class DayworkServiceImpl implements IDayworkService 
{
    @Autowired
    private DayworkMapper dayworkMapper;

    /**
     * 查询员工工作日志信息
     * 
     * @param dayworkId 员工工作日志信息主键
     * @return 员工工作日志信息
     */
    @Override
    public Daywork selectDayworkByDayworkId(Long dayworkId)
    {
        return dayworkMapper.selectDayworkByDayworkId(dayworkId);
    }

    /**
     * 查询员工工作日志信息列表
     * 
     * @param daywork 员工工作日志信息
     * @return 员工工作日志信息
     */
    @Override
    public List<Daywork> selectDayworkList(Daywork daywork)
    {
        return dayworkMapper.selectDayworkList(daywork);
    }

    /**
     * 新增员工工作日志信息
     * 
     * @param daywork 员工工作日志信息
     * @return 结果
     */
    @Override
    public int insertDaywork(Daywork daywork)
    {   daywork.setUserId(getUserId());
        daywork.setUserName(getUsername());
        daywork.setCreateTime(DateUtils.getNowDate());
        return dayworkMapper.insertDaywork(daywork);
    }

    /**
     * 修改员工工作日志信息
     * 
     * @param daywork 员工工作日志信息
     * @return 结果
     */
    @Override
    public int updateDaywork(Daywork daywork)
    {
        daywork.setUpdateTime(DateUtils.getNowDate());
        return dayworkMapper.updateDaywork(daywork);
    }

    /**
     * 批量删除员工工作日志信息
     * 
     * @param dayworkIds 需要删除的员工工作日志信息主键
     * @return 结果
     */
    @Override
    public int deleteDayworkByDayworkIds(Long[] dayworkIds)
    {
        return dayworkMapper.deleteDayworkByDayworkIds(dayworkIds);
    }

    /**
     * 删除员工工作日志信息信息
     * 
     * @param dayworkId 员工工作日志信息主键
     * @return 结果
     */
    @Override
    public int deleteDayworkByDayworkId(Long dayworkId)
    {
        return dayworkMapper.deleteDayworkByDayworkId(dayworkId);
    }
}
